/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package tenorserver;

import synchronization.SynchronizationServer;
import Settings.Settings;
import TransportLayer.IServiceListener;
import SynchronizationLayer.ISynchronizationServer;
import cryptography.BasicVerificationService;
import cryptography.IVerificationService;
import engine.NotaryEngine;
import java.net.SocketException;
import Repository.IRepositoryProxy;
import repository.RepositoryProxy;
import repository.RepositoryProxySettings;
import sntp.ISNTPClient;
import sntp.SntpClient;
import sntp.SntpClientSettings;

/**
 *
 * @author Tomasz Nowak
 */
public class TenorServer
{
	private static final String[] ModuleNames =
	{
		"SntpClient",
		"RepositoryProxy",
		"TenorServer",
		"ServiceListener"
	};

	/**
	 * @param args the command line arguments
	 */
	public static void main( String[] args ) throws SocketException, ClassNotFoundException
	{
		Settings settings = new Settings();

		settings.register(ModuleNames[0], new SntpClientSettings());
		settings.register(ModuleNames[1], new RepositoryProxySettings());
		settings.register(ModuleNames[2], new TenorServerSettings());
		settings.register(ModuleNames[2], new ServiceListenerSettings());

		settings.load();

		ISNTPClient sntpClient = new SntpClient(( SntpClientSettings ) settings.getSettings(ModuleNames[0]));
		IRepositoryProxy repository = new RepositoryProxy(( RepositoryProxySettings ) settings.getSettings(ModuleNames[1]));

		TenorServerSettings generalSettings = ( TenorServerSettings ) settings.getSettings(ModuleNames[2]);
		ServiceListenerSettings serviceListenerSettings = ( ServiceListenerSettings ) settings.getSettings(ModuleNames[3]);
		IVerificationService verificationService = new BasicVerificationService();

		IServiceListener serviceListener = new ServiceListener(serviceListenerSettings, verificationService);
//todo:conversation groups
		ISynchronizationServer synchronizationServer = new SynchronizationServer(generalSettings, repository, null);

		NotaryEngine notaryEngine = NotaryEngine.Create(repository,
																										serviceListener,
																										sntpClient,
																										synchronizationServer);
	}
}
